package com.xhs.filter;

import com.xhs.interceptor.SignInterceptor;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @desc: 检查签名过滤器
 * @projectName: java-tools-parent
 * @author: xhs
 * @date: 2023-8-27 027 15:17
 * @version: JDK 1.8
 */
@Configuration
public class SignFilter implements WebMvcConfigurer {

    /**
     * 注册拦截器
     *
     * @param registry
     * @return void
     */
    @Override
    public void addInterceptors(@NotNull InterceptorRegistry registry) {
//        // 校验规则为
//        registry.addInterceptor(new SaInterceptor(handle -> SaSignUtil.checkParamMap()))
//                //需要校验的接口
//                .addPathPatterns("/tools/getUser")
//                // 不需要校验的接口
//                .excludePathPatterns();

        // 校验规则为
        registry.addInterceptor(new SignInterceptor())
                //需要校验的接口
                .addPathPatterns("/tools/getUser","/tools/getName")
                // 不需要校验的接口
                .excludePathPatterns();
    }
}
